<style lang="less">

@import "../less/base";
  .clients-list {
    // margin-top: 10px;
    background-color: #EFEFF4;
    // padding-top: 10px;
  }

  .grey.container.pdt {
    // padding-top: 12px;
  }

</style>

<template>

<div class='page white-stage clientSeas'>
  <top-filter @item-selected="topFilterItemSelected" :filterOptions="filterOptions" @change-filter="changeFilterValue"></top-filter>
  <search-input v-if="isShowSearch" @search-change="searchChange"></search-input>

  <div class="container pdt grey" :style="containerHeight">
    <div class="clients-list">
      <scroller  class="pdscroll" :class="{'none':!clientList.length, 'hasSearch':isShowSearch}" :on-infinite="load" :on-refresh="refresh" ref="my_scroller" :noDataText="noDataText">
        <div class="pdnormal">
          <clientseas-item @on-click="onItemClick" v-for="(client, index) in clientList" :key="index" :client="client"></clientseas-item>
        </div>
      </scroller>
    </div>
  </div>

  <crm-cover v-if="isShowCover" :hideCoverOnClick="true"></crm-cover>
  <crm-tabbar :activeItem='activeItem'></crm-tabbar>

  <popup v-model="show" @on-hide="handlePopup('hide')" @on-show="handlePopup('show')" height="100%">
    <div class="popup0" v-if="show === true">
      <div :style="containerHeight" @click="hidePopup">
        <scroller style="top:44px" class="pdscroll" :class="{'none':!teamsMembers.length}" :on-infinite="loadMember" :on-refresh="refreshMember" ref="team_scroller" :noDataText="tnoDataText">
          <team-member-item @on-click="memberSelect" v-for="(teamMemberItem, index) in teamsMembers" :key="index" :client="teamMemberItem"></team-member-item>
        </scroller>
      </div>
    </div>
  </popup>
</div>

</template>

<script>

import crmTabbar from '../components/crm-tabbar'
import crmCover from '../components/crm-cover'
import topFilter from '../components/top-filter'
import teamMemberItem from '../components/team-member-item'
import clientseasItem from '../components/clientseas-item'
import SearchInput from '../components/SearchInput'
import Scroller from 'vue-scroller'
import {Popup} from 'vux'

import store from '../store'
import dropdownOption from '../components/dropdown-option';
import { SHOW_COVER } from '../store/mutation-types';

export default {

  data() {

    let overHeight = document.body.scrollHeight + 10;

    return {
      activeItem: '',
      isMore: false,
      isMoreTeam: false,
      containerHeight: 'height:' + overHeight + 'px;',
      page_size: 5,
      page_index: 1,
      isShowSearch: false,
      team_page_index: 1,
      custom_type: 0,
      show: false,
      keyword: '',
      clientList: [
        // {
        //   id: 1001,
        //   suid: 1001,
        //   head_img_url: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1489838952537&di=4c3fd0bad205ed237e850ca4ee4ddcdc&imgtype=0&src=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F279759ee3d6d55fbdf1e87f969224f4a21a4dd11.jpg',
        //   nick_name: '林丽勤',
        //   parent_name: '刘涛',
        //   custom_property: "YCJ",
        //   custom_status: 'INT',
        //   last_contact_time: '2017-03-22 15:46:35',
        //   is_manager: 1,
        //   counselorLink: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0',
        //   clientLink: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0',
        //   stateLink: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0',
        //   labels: [{
        //       name: '一岁半宝宝',
        //       link: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0'
        //     },
        //
        //     {
        //       name: '金融',
        //       link: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0'
        //     },
        //
        //     {
        //       name: '初步融洽',
        //       link: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0'
        //     },
        //   ]
        //   },
        //   {
        //     id: 1002,
        //     suid: 1002,
        //     head_img_url: 'https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/image/h%3D360/sign=e105b9f1d61b0ef473e89e58edc651a1/b151f8198618367a9f738e022a738bd4b21ce573.jpg',
        //     nick_name: '李晶晶',
        //     parent_name: '陈芳芳',
        //     custom_property: "YB#",
        //     custom_status: 'INT',
        //     last_contact_time: '2017-03-22 15:46:35',
        //     counselorLink: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0',
        //     clientLink: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0',
        //     stateLink: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0',
        //     labels: [{
        //         name: '一岁半宝宝',
        //         link: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0'
        //       },
        //
        //       {
        //         name: '金融',
        //         link: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0'
        //       },
        //
        //       {
        //         name: '初步融洽',
        //         link: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0'
        //       },
        //     ]
        //   },
        //   {
        //   id: 1003,
        //   suid: 1003,
        //   head_img_url: 'https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D360/sign=4b4e4613d443ad4bb92e40c6b2035a89/03087bf40ad162d960aed9aa14dfa9ec8b13cdc0.jpg',
        //   nick_name: '郭美美',
        //   parent_name: '陈芳芳',
        //   custom_property: "YX#",
        //   custom_status: 'INT',
        //   last_contact_time: '2017-03-22 15:46:35',
        //   counselorLink: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0',
        //   clientLink: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0',
        //   stateLink: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0',
        //   labels: [
        //     {
        //     name: '一岁半宝宝',
        //     link: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0'
        //     },
        //
        //     {
        //     name: '金融',
        //     link: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0'
        //     },
        //     {
        //       name: '初步融洽',
        //       link: 'https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=false&word=%E7%BE%8E%E5%A5%B3&step_word=&hs=2&pn=10&spn=0&di=0&pi=21202519877&rn=1&tn=baiduimagedetail&is=0%2C36045&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=750690187%2C2913691576&os=&simid=&adpicid=0&lpn=0&ln=33820&fr=&fmq=1489826129137_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=girl&bdtype=-1&oriquery=&objurl=http%3A%2F%2Ff.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fb151f8198618367a9f738e022a738bd4b21ce573.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3F4_z%26e3B08ma_z%26e3Bv54AzdH3F4jtgeAzdH3Fd8ccnAzdH3F&gsm=&rpstart=0&rpnum=0'
        //     },
        //   ]
        // }

      ],
      filterOptions: [],
      teamFilterOptions: [],
      teamsMembers: [],
      selectedClientId: null,
      noDataText:'',
      tnoDataText:'',
      originNoDataText:'暂无数据',
      filterData: {},
      loadStatus: ''
    };
  },

  components: {
    crmTabbar,
    crmCover,
    topFilter,
    clientseasItem,
    Popup,
    teamMemberItem,
    Scroller,
    SearchInput
  },

  watch: {

  },

  mounted() {
    this.callJsApi('biz.navigation.setTitle', {
      title: '工作台'
    });
  },

  methods: {
    refresh(iscroll) {
      console.log('refresh')
      this.loadStatus = 'refresh'
      this.getCustoms();
    },

    log() {
      console.log('ee');
    },

    load(iscroll) {
      console.log('load')
      this.loadStatus = 'load'
      this.getCustoms();
      // Load new data
    },

    refreshMember(iscroll) {
      console.log('refreshMember')
    },

    logMember() {
      console.log('logMember');
    },

    loadMember(iscroll) {
      console.log('loadMember')
      // this.loadMembers();
      // Load new data
    },

    searchChange (value) {
      console.log('searchChange',value)
      if (typeof this.sid !== 'undefined') {
        clearTimeout(this.sid)
      }

      this.sid = setTimeout(() => {
        if(!this.originClientList) {
          this.originClientList = this.clientList
        }
        this.emptyCustoms()
        this.keyword = value
        this.getCustoms()
      }, 1000)
    },

    hidePopup() {
      alert('你取消了分配！');
      this.show = false;
      console.log('hidePopup')
    },

    test() {
      console.log('test')
    },

    onItemClick(clientID) {
      this.teamsMembers = [];
      this.loadMembers();
      this.show = true;
      this.selectedClientId = clientID;
      console.log('clientID: ', clientID);
    },

    topFilterItemSelected(item, index) {
      if (typeof item.name !== 'undefined' && item.name === 'search') {
        this.isShowSearch  = !this.isShowSearch
      } else {
        this.isShowSearch = false
      }

      if(this.isShowSearch === false) {
        this.keyword = ''
        this.emptyCustoms()
        this.getCustoms()
      }
    },

    memberSelect(member) {
      console.log('memberSelect: ', member.suid);

      let info = {
        taget_suid: member.suid,
        custom_id: this.selectedClientId,
        distribute_type: 'GH#',
        opt_type: 'TPT'
      };

      let that = this;

      store.dispatch('distribute', info).then((response) => {
        if (response.data.errcode === 0) {
          alert('您将客户分配给成员：' + member.name);
          that.show = false;
          location.reload()
        } else {
          console.log(JSON.stringify(response.data));
        }
      }).catch((error) => {
        console.log(error)
      });
    },

    getCustoms(data) {

      let defaultData = {};
      let that = this;

      console.log('this.custom_type', this.custom_type)

      defaultData['custom_type'] = this.custom_type;
      defaultData['page_size'] = this.page_size;
      defaultData['page_index'] = this.page_index;

      if(this.keyword) defaultData['keyword'] = this.keyword

      data = Object.assign(defaultData, this.filterData, data);

      console.log('getCustoms JSON.stringify(data)', JSON.stringify(data));

      store.dispatch('getClientSeasCustoms', data).then((response) => {
        if (response.data.errcode == 0) {
          setTimeout(() => {
            let data = response.data.results.data

            if(that.loadStatus === 'refresh') {
              that.clientList = data.concat(that.clientList);
            } else {
              that.clientList = that.clientList.concat(data);
            }


            that.page_index++;

            setTimeout(() => {
              if (that.$refs.my_scroller) {
                that.$refs.my_scroller.resize()
                that.$refs.my_scroller.finishInfinite(true)
                that.$refs.my_scroller.finishPullToRefresh()
              }
            }, 100)
          }, 300)

          if(that.clientList.length) {
            that.noDataText = '';
          }
        } else {
        console.log('系统服务异常！请联系管理员!', JSON.stringify(response.data));
        }
      }).catch((error) => {
        console.log(error)
      })
    },

    emptyCustoms () {
      this.clientList = []
      this.page_index = 0
    },

    resetCustoms () {
      this.clientList = this.originClientList
    },

    loadMembers() {

      let that = this;
      let params = {
        page_index: this.team_page_index,
        page_size: this.page_size
      };

      store.dispatch('getTeams', params).then((response) => {

        setTimeout(() => {
          if (typeof response.data.results.teams !== undefined) {
            let teams = response.data.results.teams;
            that.filterUserFromTeam(teams);
          }

          if (that.$refs.team_scroller) {
            that.$refs.team_scroller.finishInfinite(true);
            that.$refs.team_scroller.finishPullToRefresh();
            if (that.teamsMembers.length > 0) {
              that.tnoDataText = ''
            }
          }
        }, 800)

        if(that.teamsMembers.length) {
          that.tnoDataText = '';
        }
        that.team_page_index++;

        console.debug(that.$refs, 'this.$refs.iscroll.refresh');

      });
    },
    //从接口中筛选出团队信息
    filterUserFromTeam(teams) {
      let temps = [];
      teams.forEach((team, index) => {
        team.team_members.forEach((member, mindex) => {
        member.team_name = team.team_name;
        temps.push(member);
        });
      });
      this.teamsMembers = this.teamsMembers.concat(temps);
      console.log('this.teamsMembers', JSON.stringify(this.teamsMembers));
    },

    //筛选器
    changeFilterValue(filterOptions) {
      var submitData = {};
      this.page_index = 0;
      filterOptions.forEach((object, index) => {
        if(object.options) {
          object.options.forEach((secObject, secIndex) => {
            submitData[secObject.name] = secObject.checked;
          });
        } else {
          submitData[object.name] = object.checked;
        }
      });
      this.filterData = submitData;
      this.emptyCustoms();
      this.getCustoms();
    },

    resetClients() {
      this.clientList = []
    },

    handlePopup(status) {

      this.team_page_index = 0;

      if (status === 'show') {} else {

      }
    }

  },

  computed: {

    isShowCover() {
      return this.$store.state.app.isShowCover
    },

    gbfilterOptions() {
      return this.$store.state.app.filterOptions;
    }

  },

  mounted() {

    let query = this.$route.query;

    this.custom_type = query.custom_type;
    this.activeItem = query.activeItem;

    this.filterOptions = this.gbfilterOptions;
    this.teamFilterOptions = this.gbfilterOptions;

    this.noDataText = this.originNoDataText;
    this.tnoDataText = this.originNoDataText;

    this.callJsApi('biz.navigation.setTitle', {
      title: '客户公海'
    });

  }


}

</script>
